﻿using System;

namespace Program17_2
{
    class Program
    {
        static void Main(string[] args)
        {
            //选择排序法
            int[] nums = { 1, 5, 9, 7, 8, 4, 3, 5, 20 };
            for (var i = 0; i < nums.Length; i++)

                Console.Write(nums[i] + " ");
            Console.WriteLine("排序后。。。");


            int minln;

            //查询余下数组种最小的下标，存放minln中
            for (var i = 0; i < nums.Length - 1; i++)
            {
                minln = i;
                for (var j = i + 1; j < nums.Length; j++)
                {
                    if (nums[j] < nums[minln])
                    {
                        minln = j;
                    }
                }
                var tmp = nums[i];
                nums[i] = nums[minln];
                nums[minln] = tmp;
            }
            for (var i = 0; i < nums.Length; i++)
                Console.Write(nums[i] + " ");

        }
    }
}
